import Vue from 'vue'
import VueRouter from 'vue-router'
import Films from '../views/films/Films.vue'
import Cinemas from '../views/films/Cinemas.vue'
import Center from '../views/films/Center.vue'
import City from '../views/films/City.vue'
import Search from '../views/films/Search.vue'
import Detail from '../views/films/Detail.vue'
import Ticket from '../views/films/Ticket.vue'
import ComingSoon from '../components/films/ComingSoon.vue'
import NowShowing from '../components/films/NowShowing.vue'

// 注册路由插件
Vue.use(VueRouter)

// 配置表
const routes = [
  {
    path: '/films',
    component: Films,
    children: [
      {
        path: '/films/comingsoon',
        component: ComingSoon
      },
      {
        path: '/films/nowshowing',
        component: NowShowing
      },
      {
        path: '/films',
        redirect: '/films/nowshowing'
      }
    ]
  },
  { path: '/cinemas', component: Cinemas },
  { path: '/city', component: City },
  { path: '/center', component: Center },
  { path: '/search', component: Search },
  { path: '/ticket/:filmId', component: Ticket },
  { path: '/detail/:myid', component: Detail },
  { path: '*', redirect: '/films' }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
